<?php

class Application_Model_DbTable_Articles extends Zend_Db_Table_Abstract
{

    protected $_name = 'articles';

public function getArticle($id)
    {
        $id = (int)$id;
        $row = $this->fetchRow('id = ' . $id);
        if (!$row) {
            throw new Exception("Impossible de trouver l'article $id");
        }
        return $row->toArray();
    }

    public function addArticle($reference,$gencod,$statut,$category,$marque,$image, $designation,$description, $price)
    {
        $data = array(
        	
        	'reference'=> $reference,
        	'gencod' => $gencod,
        	'statut'=>$statut,
        	'idCategorie' => $category,
        	'idMarque' => $marque, 
        	'image' => $image,       	
            'designation' => $designation,
        	'description' => $description,
            'price' => $price,
        
        );
        $this->insert($data);
    }

    public function updateArticle($id,$reference,$gencod,$statut,$category,$marque,$image, $designation,$description, $price)
    {
        $data = array(
            'reference'=> $reference,
        	'gencod' => $gencod,
        	'statut'=>$statut,
        	'idCategorie' => $category,
        	'idMarque' => $marque, 
        	'image' => $image,       	
            'designation' => $designation,
        	'description' => $description,
            'price' => $price,
        );
        $this->update($data, 'id = '. (int)$id);
    }

    public function deleteArticle($id)
    {
        $this->delete('id =' . (int)$id);
    }
    


}

